package io.netty.example.http.websocketx.common.util;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import io.netty.handler.codec.MessageToByteEncoder;

import java.util.List;

/**
 * @author fuguangli
 * @description 前沿类
 * @Create date:    2017/4/28
 */
public class NettyMessageEncode extends MessageToByteEncoder {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Object object, ByteBuf byteBuf) throws Exception {
        byte[] data = ByteObjConvert.objectToByte(object);
        byteBuf.writeBytes(data);
        channelHandlerContext.flush();
    }

}
